﻿@model OnlinePharmacyV001.Models.Role

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Role</legend>
        
        @Html.HiddenFor(model => model.rlId)            

        <div class="editor-label">
            @Html.LabelFor(model => model.rlName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.rlName)
            @Html.ValidationMessageFor(model => model.rlName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.rlDes)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.rlDes)
            @Html.ValidationMessageFor(model => model.rlDes)
        </div>

        <div class="editor-label">
            Permissions
        </div>
        <div class="editor-field">
        @for (int i = 0; i < @ViewBag.Pers.Count;i++ )
            {
                <div style="margin-left:20px;">
                    <input type="checkbox" value="@(ViewBag.Pers[i].perId)" 
                    @foreach(var p in Model.Permissions ){
                        if(p.perId==ViewBag.Pers[i].perId)
                        {
                            @("Checked")
                            break;
                        }
                    }                                                                                
                        name="perms" /> @(ViewBag.Pers[i].perCode) 
                </div>                
            }
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
